﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;


// 技能施放器，每一个SkillMgr拥有一个实例
public class SkillCaster
{
    Creature _caster;

    // 当前正在施放的技能
    SkillLogicBase _castingSkillLogic;

    // 当前是否在施放技能
    public bool IsCastingSkill { get { return _castingSkillLogic != null; } }

    public void Init(Creature caster)
    {
        _caster = caster;
    }

    public void CastSkill(SkillLogicBase skillLogic, Creature target = null)
    {
        _castingSkillLogic = skillLogic;
        skillLogic.StartSkill(target, onSkillEnd);
    }

    public void onSkillEnd()
    {
        _castingSkillLogic = null;
    }

    public void Loop()
    {
        if (_castingSkillLogic != null)
        {
            _castingSkillLogic.Loop(Time.deltaTime);
        }
    }
}

